<?
$txt=file_get_contents('php://input');
logfile("-----------------------------".date('Y-m-d H:i:s')."-----------------------------------",'qunar_coop_log.txt');
logfile($txt,'qunar_coop_log.txt');

if (!class_exists("go_sql")){
include("/var/www/html/new/conf/le.je");
  $le=new go_sql();
  $le->connect();
}

 
//初始化数据
$outSide = new SoapClient("http://open.12301.cc/openService/MXSE.wsdl",array('encoding' =>'UTF-8','cache_wsdl' => 0));
$ac='123492';
$pw='b4b55c7adcff5bdbc3d5a969e85cb8b2';

$ac1='16ucom';
$pw1='c33367701511b4f6020ec61ded352059';
$inSide = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac1|pw_16u=$pw1|auth_16u=true"));


$nowdate=date("Y-m-d H:i:s");

//查询去哪儿商家标识对应的密钥
$sql="select distinct supplierIdentity,signkey from uu_qunar_use";
$GLOBALS['le']->query($sql); 
$arr_supplier = array();
while($row = $GLOBALS['le']->fetch_assoc()){
	$arr_supplier[$row['supplierIdentity']] = $row['signkey'];
}
//$arr_supplier=array('DEBUGSUPPLIER'=>'DEBUGSINGKEY','FUJIANXIANXING'=>'RlVKSUFOWElBTlhJTkc=','GULONGSHAN'=>'R1VMT05HU0hBTg','MORUISHUISHIJIE'=>'TU9SVUlTSFVJU0hJSklF','landiaoxyc'=>'bGFuZGlhb3h5Yw==','YYTX'=>'WVlUWA==','LJJQ'=>'TEpKUQ==','XRGL'=>'WFJHTA==','QSWQDJC'=>'UVNXUURKQw==','DQLX'=>'RFFMWA==','HNZLGL'=>'SE5aTEdM','TXXG'=>'VFhYRw==');

$arr=array();	
parse_str($txt,$arr);
if ($arr['method']=='sendOrderEticket'){
 //重发码接口
	$rt=$arr['requestParam'];
	$arr1=json_decode($rt);
	$xml=base64_decode($arr1->data);
	$c=simpleXML_load_string($xml);
	$supplierIdentity=$c->header->supplierIdentity;
	$signkey=@$arr_supplier["$supplierIdentity"];	
    
    $ordern=(int)$c->body->orderInfo->partnerOrderId;

     //重发码
     $resend_array = array("ac"=>$ac,"pw"=>$pw,"in0"=>$ordern);
	 $resend_sms = $outSide->__soapCall("reSend_SMS_Global_PL",$resend_array);
	 $resend_xml= simplexml_load_string($resend_sms);
	 if ($resend_xml->Rec->UUerrorcode){
           	$txt_json=json_encode($resend_array);
			$txt_json.='|'.$resend_xml->Rec->UUerrorcode;
			logfile($txt_json,'coop_qunar_error.txt');		
			$code=Err_Code((int)$resend_xml->Rec->UUerrorcode);
			$describe=Err_Word((int)$resend_xml->Rec->UUerrorcode);
		}else{
		//成功
			$code=1000;
			$describe='成功';
		}
        
$string=<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<response xsi:schemaLocation="http://piao.qunar.com/2013/QMenpiaoResponseSchema QMResponseDataSchema-2.0.1.xsd" xmlns="http://piao.qunar.com/2013/QMenpiaoResponseSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<header>
		<application>Qunar.Menpiao.Agent</application>
		<processor>SupplierDataExchangeProcessor</processor>
		<version>v2.0.1</version>
		<bodyType>SendOrderEticketResponseBody</bodyType>
		<createUser>$supplierIdentity</createUser>
		<createTime>$nowdate</createTime>
		<code>$code</code>
		<describe>$describe</describe>
	</header>
	<body xsi:type="SendOrderEticketResponseBody">
		<message></message>
	</body>
</response>
XML;
		$js_sing= singed($string,$signkey);
		echo $js_sing;
}elseif ($arr['method']=='getProductByQunar'){// 获取产品信息

    $rt=$arr['requestParam'];
	$arr1=json_decode($rt);
	$xml=base64_decode($arr1->data);
	$c=simpleXML_load_string($xml);
	$supplierIdentity=$c->header->supplierIdentity;
	$signkey=@$arr_supplier["$supplierIdentity"];		
	$method = $c->body->method; //方法
	$count = 0;	
	if($method == 'SINGLE'){//获取单个产品信息
	    $count = 1;
		$data_array = array();		
		$data_array = get_date($c->body->resourceId,$inSide,$outSide,$ac,$pw,$count);
		$string = string_XML($data_array);
		$string_header = body_Date($string,$count);
		$js_sing= singed($string_header,$signkey);
        echo $js_sing;
	}elseif($method == 'ALL'){//获取全部产品信息
		$currentPage =(int)$c->body->currentPage;// 当前页数
		$pageSize =(int)$c->body->pageSize; //每页记录数
		$begin = ($currentPage-1)*$pageSize;//计算分页数
		
		$count_select = "select count(id) as count from uu_qunar_use where supplierIdentity='$supplierIdentity' ";
		$GLOBALS['le']->query($count_select); 
		$GLOBALS['le']->fetch_assoc();
		$count = $GLOBALS['le']->f('count'); //获取总数
		
		
		$search = "select tid_aid from uu_qunar_use where supplierIdentity='$supplierIdentity' limit $begin ,$pageSize";
		$GLOBALS['le']->query($search);	
		$data = array();
		while($row=$GLOBALS['le']->fetch_assoc()){ 
			$data[] = $row;
		}
		foreach($data as $row){
			$data_array = array();
			$data_array = get_date($row['tid_aid'],$inSide,$outSide,$ac,$pw,$count);	
			$string.= string_XML($data_array);	
		}
		$string_header = body_Date($string,$count);
		$js_sing= singed($string_header,$signkey);
		echo $js_sing;
	}
}elseif ($arr['method']=='createOrderForAfterPaySync' || $_REQUEST['testI']=='test') {
//下单接口 123492  | b4b55c7adcff5bdbc3d5a969e85cb8b2 | 去哪儿 
//这里需要下单程序

	$rt=$arr['requestParam'];
	$arr1=json_decode($rt);
	$xml=base64_decode($arr1->data);
	$c=simpleXML_load_string($xml);
	$supplierIdentity=$c->header->supplierIdentity;
	$signkey=@$arr_supplier["$supplierIdentity"];	
	
	$tids=$c->body->orderInfo->product->resourceId;
	$a_tids=explode('_',$tids);
	$tid=$a_tids[0];
	
	$tid=$tid?$tid:206;//这行测试
	$remotenum=(string)$c->body->orderInfo->orderId;
	$tprice=(string)$c->body->orderInfo->product->sellPrice;
	$tnum=(int)$c->body->orderInfo->orderQuantity;
	$playtime=(string)$c->body->orderInfo->product->visitDate;
	$ordername=(string)$c->body->orderInfo->contactPerson->name;
	$ordertel=(string)$c->body->orderInfo->contactPerson->mobile;
	$IDkard =(string)$c->body->orderInfo->person->credentials;
	//供应商ID需要获取
	$aid=$a_tids[1];
	$aid=$aid?$aid:2;//临时
	$remotenum=$remotenum?$remotenum:'123';//临时
	$tprice=$tprice?$tprice:400;//临时
	$tnum=$tnum?$tnum:2;//临时
	$playtime=$playtime?$playtime:date('Y-m-d');//临时
	$ordername=$ordername?$ordername:'test123';//临时
	$ordertel=$ordertel?$ordertel:'15959110796';//临时
	
	$str="select landid from uu_jq_ticket where id='$tid' limit 1";	
	$GLOBALS['le']->query($str);
	$GLOBALS['le']->fetch_assoc();
	$lid=$GLOBALS['le']->f('landid');
	
	if($lid == 4968) {$sms=1;} else {$sms = 0;}
	
	$arr_data=array("ac"=>$ac,"pw"=>$pw,"in0"=>$lid,"in1"=>$tid,"in2"=>$remotenum,"in3"=>$tprice,"in4"=>$tnum,"in5"=>$playtime,"in6"=>$ordername,"in7"=>$ordertel,"in8"=>"","in9"=>$sms,"in10"=>2,"in11"=>0,"in12"=>"","in13"=>"","in14"=>0,"in15"=>0,"in16"=>$aid,"in17"=>$IDkard);
	$code="";
	$ordern="";
	$describe="";
	$cxml=$outSide->__soapCall("PFT_Order_Submit",$arr_data);
	$cx=simpleXML_load_string($cxml);
	if ($cx->Rec->UUerrorcode){
		if((int)$cx->Rec->UUerrorcode==122){
			//授信不足，提醒供应商给分销商授信
			$str="select mobile from pft_member where id='$landid' limit 1";	
			$GLOBALS['le']->query($str);
			$GLOBALS['le']->fetch_assoc();
			$aid_Tel=$GLOBALS['le']->f('mobile');
			$inSide->Send_SMS_V($aid_Tel,'系统公告:您授信给分销商[去哪儿]的授信余额不足，请尽快补充授信，避免影响销量');
		}
		$txt_json=json_encode($arr_data);
		$txt_json.='|'.$cx->Rec->UUerrorcode;
		logfile($txt_json,'coop_qunar_error.txt');		
		$orderStatus='PREPAY_ORDER_PRINT_FAILED';
		$code=Err_Code((int)$cx->Rec->UUerrorcode);
		$describe=Err_Word((int)$cx->Rec->UUerrorcode);
	}else{
	//成功
		$ordern=$cx->Rec->UUordernum;
		
		$str="insert into pft_coop_qunar_record (orderid,dtype) values ('$ordern',9)";
		$GLOBALS['le']->query($str);
		
		$code=1000;
		$orderStatus='PREPAY_ORDER_PRINT_SUCCESS';
		$describe='成功';
		
		//给用户发完短信后也需要通知去哪儿
		// file_get_contents("http://coop.12301.cc/callback/post_qunar_sms.php?ordern=$ordern");
	}
	
$string=<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy v2013 (http://www.altova.com)-->
<response xsi:schemaLocation="http://piao.qunar.com/2013/QMenpiaoResponseSchema QMResponseDataSchema-2.0.1.xsd" xmlns="http://piao.qunar.com/2013/QMenpiaoResponseSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<header>
		<application>Qunar.Menpiao.Agent</application>
		<processor>SupplierDataExchangeProcessor</processor>
		<version>v2.0.1</version>
		<bodyType>CreateOrderForAfterPaySyncResponseBody</bodyType>
		<createUser>$supplierIdentity</createUser>
		<createTime>$nowdate</createTime>
		<code>$code</code>
		<describe>$describe</describe>
	</header>
	<body xsi:type="CreateOrderForAfterPaySyncResponseBody">
		<orderInfo>
			<partnerorderId>$ordern</partnerorderId>
			<orderStatus>$orderStatus</orderStatus>
		</orderInfo>
	</body>
</response>
XML;
	// print_R($string);
	$bstr=base64_encode($string);

	$signed=strtoupper(md5($signkey.$bstr));

	$arr=array('data'=>$bstr,'signed'=>$signed,'securityType'=>'MD5');
	echo json_encode($arr);

}
elseif ($arr['method']=='noticeOrderRefundedByQunar')
{
//这里是撤改接口
	$rt=$arr['requestParam'];
	$arr1=json_decode($rt);
	$xml=base64_decode($arr1->data);
	$c=simpleXML_load_string($xml);
	$supplierIdentity=$c->header->supplierIdentity;
	$signkey=@$arr_supplier["$supplierIdentity"];
	
	$ordern=$c->body->orderInfo->partnerorderId;
	$tnum=$c->body->orderInfo->orderQuantity;
	$rnum=$c->body->orderInfo->refundQuantity;
	$refundSeq=$c->body->orderInfo->refundSeq;
	
	//查询是否有修改记录
	$str="select refundSeq,tnum from pft_coop_qunar_record where orderid='$ordern' and status=0 and dtype=0 order by id desc limit 1";	
	$GLOBALS['le']->query($str);
	$GLOBALS['le']->fetch_assoc();
	$refundSeq_r=$GLOBALS['le']->f('refundSeq');
	$tnum_r=$GLOBALS['le']->f('tnum');
	$tnum=($tnum_r)?$tnum_r:$tnum;
	
	$rnum=($rnum==0)?$tnum:$rnum;
	$num=$tnum-$rnum;
	
	if ($refundSeq!=$refundSeq_r){
		$arr_data=array("ac"=>$ac,"pw"=>$pw,"in0"=>$ordern,"in1"=>$num);
		$cxml=$outSide->__soapCall("Order_Change_Pro",$arr_data);
		$cx=simpleXML_load_string($cxml);
		if ($cx->Rec->UUerrorcode){
			$txt_json=json_encode($arr_data);
			$txt_json.='|'.$cx->Rec->UUerrorcode;
			logfile($txt_json,'coop_qunar_error.txt');		
			$code=Err_Code((int)$cx->Rec->UUerrorcode);
			$describe=Err_Word((int)$cx->Rec->UUerrorcode);
		}else{
		//成功
			$code=1000;
			$describe='成功';
			//修改成功记录
			$str="insert pft_coop_qunar_record set orderid='$ordern',refundSeq='$refundSeq',tnum=$num,rnum=$rnum";
			$GLOBALS['le']->query($str);
		}
	
$string=<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<response xsi:schemaLocation="http://piao.qunar.com/2013/QMenpiaoResponseSchema QMResponseDataSchema-2.0.1.xsd" xmlns="http://piao.qunar.com/2013/QMenpiaoResponseSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<header>
		<application>Qunar.Menpiao.Agent</application>
		<processor>SupplierDataExchangeProcessor</processor>
		<version>v2.0.1</version>
		<bodyType>NoticeOrderRefundedByQunarResponseBody</bodyType>
		<createUser>$supplierIdentity</createUser>
		<createTime>$nowdate</createTime>
		<code>$code</code>
		<describe>$describe</describe>
	</header>
	<body xsi:type="NoticeOrderRefundedByQunarResponseBody">
		<message></message>
	</body>
</response>
XML;

		$bstr=base64_encode($string);
	
		$signed=strtoupper(md5($signkey.$bstr));
	
		$arr=array('data'=>$bstr,'signed'=>$signed,'securityType'=>'MD5');
		echo json_encode($arr);
	}
}
elseif ($arr['method']=='testAlive')
{
//心跳检测
	echo 'alive';
}


/* echo $string;
{
"data":"data"
"signed":"signed"
"securityType":"MD5"
}

 */
//以下都是函数部分
/*
function lmm_post($post_data = array()){
	$url='http://www.12301.cc/qunar/noticeOrderRefundApproveResult.php'; 
	$o=""; 
	foreach ($post_data as $k=>$v){ 
	$o.= "$k=".urlencode($v)."&"; 
	} 
	$post_data=substr($o,0,-1); 
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_POST, 1); 
	curl_setopt($ch, CURLOPT_HEADER, 0); 
	curl_setopt($ch, CURLOPT_URL,$url); 
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 
	curl_exec($ch);
}*/
function body_Date($string_content,$count){ //xml的头部部分
 $string=<<<XML
<?xml version="1.0" encoding="UTF-8"?>
<response xsi:schemaLocation="http://piao.qunar.com/2013/QMenpiaoResponseSchema QMResponseDataSchema-2.0.1.xsd" xmlns="http://piao.qunar.com/2013/QMenpiaoResponseSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
	<application>Qunar.Menpiao.Agent</application>
	<processor>SupplierDataExchangeProcessor</processor>
	<version>v2.0.1</version>
	<bodyType>GetProductByQunarResponseBody</bodyType>
	<createUser>SupplierSystemName</createUser>
	<createTime>$nowdate</createTime>
	<code>1000</code>
	<describe>成功</describe>
</header>
<body xsi:type="GetProductByQunarResponseBody">
	<count>$count</count>   
	<productInfos>
      $string_content
	</productInfos>
</body>
</response>
XML;
// print_R($string);
	return $string;
}

function singed($string,$signkey){ //这里是加密
		$bstr=base64_encode($string);
		$signed=strtoupper(md5($signkey.$bstr));
		$arr=array('data'=>$bstr,'signed'=>$signed,'securityType'=>'MD5');
		
		return json_encode($arr);
}
function get_date($tids,$inSide,$outSide,$ac,$pw,$count){ // 这里是获取产品信息数据
		$a_tids=explode('_',$tids);
		$tid=$a_tids[0]; //门票id
		$aid = $a_tids[1]; //供应商id
		
		//$str="select a.id as lid,a.title as ltitle,b.title as ttitle ,a.address,b.pay,b.delaydays,b.notes,b.tprice,b.ddays,b.pid,b.getaddr from uu_land a inner join uu_jq_ticket b on (a.id = b.landid) left join uu_products c on(b.pid = c.id) where b.id='$tid' and c.apply_limit = 1 and c.p_status = 0 limit 1";	
		
		$str="select a.id as lid,a.title as ltitle,a.jqts,b.title as ttitle ,a.address,a.delaytime,b.pay,b.buy_limit_up,b.buy_limit_low,b.delaydays,b.notes,b.tprice,b.ddays,b.pid,b.getaddr,b.cancel_auto_onMin,d.dhour from uu_land a inner join uu_jq_ticket b on (a.id = b.landid) left join uu_products c on(b.pid = c.id) left join uu_land_f d on(b.id = d.tid) where b.id='$tid' and c.apply_limit = 1 and c.p_status = 0 limit 1";
		
	    $GLOBALS['le']->query($str);
		$GLOBALS['le']->fetch_assoc();		
		
		$resourceId = $tids; //去哪儿供应商产品id
		$sightName = $GLOBALS['le']->f('ltitle'); //景区名称
		$city = $GLOBALS['le']->f('address'); //目的地
		$sightAddress = $GLOBALS['le']->f('address'); //景区地址
		$productName = $GLOBALS['le']->f('ttitle'); //产品名称
		$pay = $GLOBALS['le']->f('pay'); //支付方式
		$marketPrice = $GLOBALS['le']->f('tprice')* 100;  //门市价
		$remind =$GLOBALS['le']->f('jqts'); //使用说明
		$feeInfo =$GLOBALS['le']->f('notes');  //费用说明			
		$smsTemplet = $GLOBALS['le']->f('getaddr');//取票信息
		$bookAdvanceDay =$GLOBALS['le']->f('ddays') == 0 ? '' : $GLOBALS['le']->f('ddays');  //提前预订的天数
		$bookAdvanceTime = $GLOBALS['le']->f('dhour');  //提前预定时间
		$autoCancelTime = $GLOBALS['le']->f('cancel_auto_onMin');  //不支付自动取消订单时间
		$useAdvanceHours = explode('|',$GLOBALS['le']->f('delaytime')); //延迟验证时间
		$useAdvanceHour = $useAdvanceHours[0] == 0 ? '' : $useAdvanceHours[0] ; //延迟验证时间（取小时）
		// $minimum =  $GLOBALS['le']->f('buy_limit_low');  //最少购买票数
		// $maximum =  $GLOBALS['le']->f('buy_limit_up');  //最多购买票数		
	    $nameRequired = 'TRUE' ; //需要取票人姓名
		$visitPersonRequiredForQuantity = '999'; //每几个游客共享一个游客信息
		$refundInfo = '未使用可申请退款';   //默认
		
		if($pay == 1){ //支付方式 PREPAY在线支付 CASHPAY景区支付
			$paymentType = 'PREPAY';
		}elseif($pay == 0){ 
			$paymentType ='CASHPAY'; 
		}
		
		$delaydays = $GLOBALS['le']->f('delaydays'); //允许推迟游玩的天数
		
		if($delaydays == 0){
			$validType = 'USE_DATE';	// 当天有效
			$daysAfterUseDateValid = 1;
			$searchday = 90;
		}else { 
			$validType ='BETWEEN_USE_DATE_AND_N_DAYSAFTER'; //多少天内有效
			$daysAfterUseDateValid = $delaydays;//游客选定的游玩日期起x天内有效
			$searchday =$delaydays;
		} 
		
		$pid = $GLOBALS['le']->f('pid'); //产品id
		$i_startime = time(date('Y-m-d'));
		$i_endtime = $i_startime + 86400*$searchday;
		// print_r($validType);
		$calendarPrices = '';
		for($i=$i_startime;$i<=$i_endtime;$i+= 86400){   
			$itime = date('Y-m-d',$i);
			$yz_order = $inSide->get_Dynamic_Price_Merge($pid,$itime,1,"","",1,"");//marketPrice票面价
			if($yz_order == -1) continue;
			$sellPrice_data =$inSide->Dynamic_Price_And_Storage($ac,$pid,$itime,1,0,1,$aid); //查询去哪儿结算价
			if($sellPrice_data == 105 || $sellPrice_data ==1065 || $sellPrice_data ==103) continue;
			$sellPrice_data_xml =simpleXML_load_string($sellPrice_data); 
			$sellPrice = (string)$sellPrice_data_xml->Rec->UUsprice;
			// 9999 表示无限 
			$sellstock = ((string)$sellPrice_data_xml->Rec->UUstorage == -1) ? '9999':(string)$sellPrice_data_xml->Rec->UUstorage;
			$minimum =  1;  //最少购买票数
			$maximum =  $sellstock;  //最多购买票数
			// if($sellstock == 0){$minimum=0;$maximum=0;}
   	
			$smsTemplet = '您将会在3-5分钟内收到电子票，在景区售票处取票入园。';//短信模板
			if($sellstock !=0){
			$calendarPricesss=<<<XML
<calendarPrice>
<useDate>$itime</useDate>
<marketPrice>$marketPrice</marketPrice>   
<sellPrice>$yz_order</sellPrice>
<sellstock>$sellstock</sellstock>
<minimum>$minimum</minimum>
<maximum>$maximum</maximum>
</calendarPrice>
XML;
			$calendarPrices .= $calendarPricesss;	 
			}
		}
		$eticketType = 'S_STRING'; //电子票类型：短信
		$data_array= array( //需要的参数
			'count'=>$count,
			'resourceId'=>$tids,
			'sightName'=>$sightName,
			'city'=>$city,
			'sightAddress'=>$sightAddress,
			'productName'=>$sightName.$productName,
			'paymentType'=>$paymentType,
			'validType'=>$validType,
			'bookAdvanceTime'=>$bookAdvanceTime,
			'daysAfterUseDateValid'=>$daysAfterUseDateValid,
			'remind'=>$remind,
			'smsTemplet'=>$smsTemplet,
			'eticketType'=>$eticketType,
			'calendarPrices'=>$calendarPrices,
			'feeInfo'=>$feeInfo,
			'bookAdvanceDay'=>$bookAdvanceDay,
			'autoCancelTime'=>$autoCancelTime,
			'useAdvanceHour'=>$useAdvanceHour,
			'nameRequired' =>$nameRequired,
			'visitPersonRequiredForQuantity'=>$visitPersonRequiredForQuantity,
			'refundInfo' => $refundInfo			
		);
		return $data_array;
}

function string_XML($string_array,$calendarPrices=null){ //xml的body部分
$string_content =<<<XML
			<productInfo>
				<baseInfo>
					<resourceId>{$string_array['resourceId']}</resourceId>  
					<sights>
						<sight>
							<sightName>{$string_array['sightName']}</sightName> 
							<sightAddress>{$string_array['sightAddress']}</sightAddress>
							<city>{$string_array['city']}</city>
							<sightlon></sightlon>
							<sightlat></sightlat>
						</sight>
					</sights>
					<productName>{$string_array['productName']}</productName>   
				</baseInfo>
				<bookConfig>
					<paymentType>{$string_array['paymentType']}</paymentType>
					<advanceOption>
						<bookAdvanceDay>{$string_array['bookAdvanceDay']}</bookAdvanceDay>
						<bookAdvanceTime>{$string_array['bookAdvanceTime']}</bookAdvanceTime>
						<useAdvanceHour>{$string_array['useAdvanceHour']}</useAdvanceHour>
					</advanceOption>
					<autoCancelTime>{$string_array['autoCancelTime']}</autoCancelTime>
					<contactPersonRequired>
						<nameRequired>{$string_array['nameRequired']}</nameRequired>
						<namePinyinRequired></namePinyinRequired>
						<emailRequired></emailRequired>
						<addressRequired></addressRequired>
					</contactPersonRequired>
					<bookPersonType>CONTACT_PERSON</bookPersonType>
					<visitPersonRequiredForQuantity>{$string_array['visitPersonRequiredForQuantity']}</visitPersonRequiredForQuantity>
					<visitPersonRequired>
						<nameRequired>{$string_array['nameRequired']}</nameRequired>
						<namePinYinRequired></namePinYinRequired>
						<credentialsRequired></credentialsRequired>
						<credentialsRequiredTypes></credentialsRequiredTypes>
						<userRequiredDefined1></userRequiredDefined1>
						<userRequiredDefined2></userRequiredDefined2>
					</visitPersonRequired>
					<perPhoneMaximum></perPhoneMaximum>
					<perPhoneMaximumType></perPhoneMaximumType>
				</bookConfig>
				<priceConfig>
					<validType>{$string_array['validType']}</validType>
					<daysAfterUseDateValid>{$string_array['daysAfterUseDateValid']}</daysAfterUseDateValid>
					<daysAfterBookDateValid></daysAfterBookDateValid>
					<dayUseTimePeriod></dayUseTimePeriod>						
					<calendarPrices>
						{$string_array['calendarPrices']}
					</calendarPrices>
					<periodPrice>
						<periodStart></periodStart>
						<periodEnd></periodEnd>
						<validWeek></validWeek>
						<invalidDate></invalidDate>
						<marketPrice></marketPrice>
						<sellPrice></sellPrice>
						<sellstock></sellstock>
						<minimum></minimum>
						<maximum></maximum>
					</periodPrice>
				</priceConfig>
				<promoteConfig>
					<cashBackMoney></cashBackMoney>
				</promoteConfig>
				<productDescription>
					<feeInfo>{$string_array['feeInfo']}</feeInfo>
					<feeInclude></feeInclude>
					<feeExclude></feeExclude>
					<pickupTime></pickupTime>
					<pickupAddress></pickupAddress>
					<remind>{$string_array['remind']}</remind>
					<refundOption>
						<canRefund>TRUE</canRefund>
						<refundApplyTimeBeforeValidEndDay></refundApplyTimeBeforeValidEndDay>
						<refundChargeType>ORDER</refundChargeType>
						<refundCharge>100</refundCharge>
						<refundInfo>{$string_array['refundInfo']}</refundInfo>
					</refundOption>
				</productDescription>
				<otherConfig>
					<telephone></telephone>
					<salePeriods>
						<salePeriod>
							<saleStartTime></saleStartTime>
							<saleEndTime></saleEndTime>
						</salePeriod>
					</salePeriods>
					<smsTemplet>{$string_array['smsTemplet']}</smsTemplet>
					<eticketType>{$string_array['eticketType']}</eticketType>
				</otherConfig>
			</productInfo>
XML;
	return $string_content;
}
function logfile($txt,$path){
	$fp = fopen($path,"a");
	flock($fp, LOCK_EX) ;
	fwrite($fp,$txt."\n");
	flock($fp, LOCK_UN);
	fclose($fp); 
}
function Err_Code($errcode){
	$arr_X_code=array(101=>20027,103=>20011,105=>12001,107=>90005,112=>20006,115=>90007,116=>14007,119=>13009,123=>13001,130=>20005,131=>20006,133=>14009,134=>14010,1061=>20004,1062=>20022,1065=>13007,1071=>20010,1072=>20007,1075=>13004,1077=>13005);
	$ecode=@$arr_X_code[$errcode];
	if (!$ecode) $ecode=90001;
	return $ecode;
}
function Err_Word($errcode){
	$arr_X_word=array(
		103=>'您选择的出行日期格式不合法',
		101=>'创建订单异常，用户未登陆',
		105=>'产品不存在，不可预订',
		107=>'供应商交互XML解析错误',
		112=>'创建订单异常，取票人手机号码异常',
		115=>'web服务调用错误',
		116=>'电子票最多重复发送5次',
		119=>'订单状态不正确，不能重新发送入园凭证',
		122=>'资金账户余额不足',
		123=>'订单不存在',
		130=>'创建订单异常，取票人邮箱格式不合法',
		131=>'创建订单异常，取票人手机号码异常',
		133=>'订单消费失败，订单还未到有效使用日期',
		134=>'订单消费失败，订单已超过有效使用日期',
		1061=>'创建订单异常，选购产品不存在',
		1062=>'创建订单异常，库存不足',
		1063=>'总库存已售罄',		
		1065=>'订单产品价格信息异常',
		1066=>'商品票类数据出错',
		1067=>'商品数据出错',
		1068=>'商品需提前预定',
		1069=>'已超过当日购买的时间',
		1071=>'创建订单异常，出行日期为空',
		1072=>'创建订单异常，取票人姓名异常',
		1075=>'订单存在，但不属于该用户',
		1077=>'该订单无法修改',
	);
	$eword=@$arr_X_word[$errcode];
	if (!$eword) $eword='其他错误';
	return $eword;
}

/* 错误代码注释 
101=>'无授权，拒绝连接'=>20027=>'创建订单异常，用户未登陆'
105=>'数据为空或重叠'=>12001=>'产品不存在，不可预订'
107=>'返回数据非XML格式'=>90005=>'供应商交互XML解析错误'
112=>'手机格式错误'=>20006=>'创建订单异常，取票人手机号码异常
115=>'网站服务出错，请联系技术开发人员'=>90007=>'web服务调用错误'
116=>'短信重发次数过多'=>14007=>'电子票最多重复发送5次'
119=>'订单状态出错，请联系技术人员'=>13009=>'订单状态不正确，不能重新发送入园凭证'
123=>'未知的订单号'=>13001=>'订单不存在'
130=>'邮件格式错误'=>20005=>'创建订单异常，取票人邮箱格式不合法'
131=>'手机格式错误'=>20006=>'创建订单异常，取票人手机号码异常'
133=>'时间未到'=>14009=>'订单消费失败，订单还未到有效使用日期'
134=>'时间超过'=>14010=>'订单消费失败，订单已超过有效使用日期'
1061=>'无此日期的价格'=>20004=>'创建订单异常，选购产品不存在'
1062=>'库存已售罄'=>20022=>'创建订单异常，库存不足'
1065=>'无此商品的分销价格'=>13007=>'订单产品价格信息异常'
1071=>'游玩时间必填'=>20010=>'创建订单异常，出行日期为空'
1072=>'取票人姓名、手机不能为空'=>20007=>'创建订单异常，取票人姓名异常'
1075=>'远端订单号不能重复'=>13004=>'订单存在，但不属于该用户'
1077=>'订单不是未使用状态，无法取消或修改'=>13005=>'该订单无法修改'
*/
?>